package com.changan.error;

/**
 * 业务异常模型
 */
public class BusinessException extends Exception implements CommonError{
    private CommonError commonError;

    public BusinessException(CommonError commonError){
        super();
        this.commonError = commonError;
    }
    public BusinessException(CommonError commonError,String errMsg){
        super();
        this.commonError = commonError;
        this.commonError.setErrMsg(errMsg);
    }

    /**
     * 获取错误码
     *
     * @return
     */
    @Override
    public int getErrCode() {
        return commonError.getErrCode();
    }

    /**
     * 获取错误消息
     *
     * @return
     */
    @Override
    public String getErrMsg() {
        return commonError.getErrMsg();
    }

    /**
     * @param errMsg
     * @return 返回实现这个接口的子类
     */
    @Override
    public CommonError setErrMsg(String errMsg) {
        commonError.setErrMsg(errMsg);
        return this;
    }
}
